﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Notoric.ViewModel.Elements.CWNotation
{
    /// <summary>
    /// Adapts a <see cref="Model.Elements.CWNotation.Attachment"/> instance to a Windows Presentation Foundation view.
    /// </summary>
    public abstract class Attachment : ViewModelElement
    {
        #region Constructors

        /// <summary>
        /// Creates a new <see cref="Attachment"/> instance.
        /// </summary>
        /// <param name="owner">
        /// <para>
        /// Type: <see cref="Staff"/>
        /// </para>
        /// <para>
        /// The element that directly owns this element.
        /// </para>
        /// </param>
        /// <param name="adaptedElement">
        /// <para>
        /// Type: <see cref="Model.Elements.CWNotation.Attachment"/>
        /// </para>
        /// <para>
        /// The adapted model element instance.
        /// </para>
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="adaptedElement"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="NullReferenceException">
        /// <paramref name="owner"/> is <see langword="null"/>.
        /// The values of the <see cref="ViewModelElement.UndoStack"/> and <see cref="ViewModelElement.RedoStack"/> properties
        /// are passed directly to the base class (<see cref="ViewModelElement"/>) constructor. Thus, there is not
        /// an occasion to react with a more appropriate exception.
        /// </exception>
        public Attachment(Staff owner, Model.Elements.CWNotation.Attachment adaptedElement)
            : base(adaptedElement, owner, owner.UndoStack, owner.RedoStack)
        {
			
        }

        #endregion

        #region Public Methods

        /// <summary>
        /// Identifies the type of a given attachment and creates the correct view-model adapter for it.
        /// </summary>
        /// <param name="owner">
        /// <para>
        /// Type: <see cref="Staff"/>
        /// </para>
        /// <para>
        /// The staff that will directly own the created object.
        /// </para>
        /// </param>
        /// <param name="adaptedElement">
        /// <para>
        /// Type: <see cref="Model.Elements.CWNotation.Attachment"/>
        /// </para>
        /// <para>
        /// The model element for which the adapter is being created.
        /// </para>
        /// </param>
        /// <returns>
        /// <para>
        /// Type: <see cref="Attachment"/>
        /// </para>
        /// <para>
        /// The created view-model adapter.
        /// </para>
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// The <paramref name="owner"/> or <paramref name="adaptedElement"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// The type of the <paramref name="adaptedElement"/> is unknown.
        /// </exception>
        public static Attachment CreateAdapter(Staff owner, Model.Elements.CWNotation.Attachment adaptedElement)
        {
            if (owner == null)
                throw new ArgumentNullException("owner");
            if (adaptedElement == null)
                throw new ArgumentNullException("adaptedElement");

            if (adaptedElement is Model.Elements.CWNotation.Beam)
                return new Beam(owner, adaptedElement as Model.Elements.CWNotation.Beam);
            else if (adaptedElement is Model.Elements.CWNotation.DynamicMark)
                return new DynamicMark(owner, adaptedElement as Model.Elements.CWNotation.DynamicMark);
            else if (adaptedElement is Model.Elements.CWNotation.DynamicsProgressMark)
                return new DynamicsProgressMark(owner, adaptedElement as Model.Elements.CWNotation.DynamicsProgressMark);

            throw new ArgumentException("Unknown model element type!", "adaptedElement");
        }

        #endregion

        #region Public Properties



        #endregion
    }
}
